package com.material.web.controller.pound;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.material.common.annotation.Log;
import com.material.common.core.controller.BaseController;
import com.material.common.core.domain.AjaxResult;
import com.material.common.enums.BusinessType;
import com.material.pound.domain.FuelPoundIncentive;
import com.material.pound.service.IFuelPoundIncentiveService;
import com.material.common.utils.poi.ExcelUtil;
import com.material.common.core.page.TableDataInfo;

/**
 * 磅单奖惩记录Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/pound/incentive")
public class FuelPoundIncentiveController extends BaseController
{
    @Autowired
    private IFuelPoundIncentiveService fuelPoundIncentiveService;

    /**
     * 查询磅单奖惩记录列表
     */
    @PreAuthorize("@ss.hasPermi('pound:incentive:list')")
    @GetMapping("/list")
    public TableDataInfo list(FuelPoundIncentive fuelPoundIncentive)
    {
        startPage();
        List<FuelPoundIncentive> list = fuelPoundIncentiveService.selectFuelPoundIncentiveList(fuelPoundIncentive);
        return getDataTable(list);
    }

    /**
     * 导出磅单奖惩记录列表
     */
    @PreAuthorize("@ss.hasPermi('pound:incentive:export')")
    @Log(title = "磅单奖惩记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FuelPoundIncentive fuelPoundIncentive)
    {
        List<FuelPoundIncentive> list = fuelPoundIncentiveService.selectFuelPoundIncentiveList(fuelPoundIncentive);
        ExcelUtil<FuelPoundIncentive> util = new ExcelUtil<FuelPoundIncentive>(FuelPoundIncentive.class);
        util.exportExcel(response, list, "磅单奖惩记录数据");
    }

    /**
     * 获取磅单奖惩记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('pound:incentive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fuelPoundIncentiveService.selectFuelPoundIncentiveById(id));
    }

    /**
     * 新增磅单奖惩记录
     */
    @PreAuthorize("@ss.hasPermi('pound:incentive:add')")
    @Log(title = "磅单奖惩记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FuelPoundIncentive fuelPoundIncentive)
    {
        return toAjax(fuelPoundIncentiveService.insertFuelPoundIncentive(fuelPoundIncentive));
    }

    /**
     * 修改磅单奖惩记录
     */
    @PreAuthorize("@ss.hasPermi('pound:incentive:edit')")
    @Log(title = "磅单奖惩记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FuelPoundIncentive fuelPoundIncentive)
    {
        return toAjax(fuelPoundIncentiveService.updateFuelPoundIncentive(fuelPoundIncentive));
    }

    /**
     * 删除磅单奖惩记录
     */
    @PreAuthorize("@ss.hasPermi('pound:incentive:remove')")
    @Log(title = "磅单奖惩记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fuelPoundIncentiveService.deleteFuelPoundIncentiveByIds(ids));
    }
}
